<!doctype html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta charset="UTF-8" />
	<title>登录</title>
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
		<!-- 为移动设备添加 viewport -->
		<meta name="viewport" content="width=device-width,initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
		<meta name="format-detection" content="telphone=no, email=no" />
		<!--下面三个是清除缓存 微信浏览器缓存严重又无刷新；这个方法调试的时候很方便-->
		<meta http-equiv="Pragma" content="no-cache"/>
		<meta http-equiv="Cache-Control" content="no-cache"/>
		<meta http-equiv="Expires" content="0"/>
		<!--ios浏览器里面数字被当做电话号码导致变色-->
		<meta name="format-detection" content="telephone=no"/>
		<meta http-equiv="x-rim-auto-match" content="none"/>
	<link rel="stylesheet" type="text/css" href="css/index.css"/>
</head>
	<body class="integral-body">
		<header class="logo-header">
			<div class="i-logo">
				<img src="img/i-logo.png"/>
			</div>
		</header>
		<section class="logo-content">
			<div class="login-warpper">
				<form>
					<div class="form-control">
						<input type="text" placeholder="输入手机号" class="control-text" id="phone"/>
					</div>
					<div class="form-control">
						<input type="password" placeholder="输入密码" class="control-text" id="password"/>
					</div>
					<div class="form-control">
						<a href="javascript:;" class="control-login">登录</a>
					</div>
				</form>
			</div>
		</section>
		<footer class="logo-else">
			<div class="else-tit">
				<h4>第三方登录</h4>
			</div>
			<div class="else-icon clearfix">
				<a href="javascript:;" class="icon sina" id="sinaBtn"><img src="img/icon_sina.png"/></a>
				<a href="javascript:;" class="icon wechat" id="weixinBtn"><img src="img/icon_wechat.png"/></a>
				<!--<a href="javascript:;" class="icon qq" id="qqBtn"><img src="img/icon_qq.png"/></a>-->
			</div>
		</footer>
		<!--弹框提醒-->
		<div class="dialog">
			<div class="dialog-content"><span class="valid-font"></span></div>
		</div>
	</body>
	<script src="js/jquery-1.9.1.js" type="text/javascript" charset="utf-8"></script>
<script src="js/md5.js"></script>
	<script>

		$("#phone").on("blur",function(){
            var myreg = /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1})|(17[0-9]{1}))+\d{8})$/;
            if(!myreg.test($("#phone").val())){
                $(".valid-font").text("请输入正确的电话号码")
                $(".dialog").fadeIn();
                setTimeout(function () {
                    $(".dialog").fadeOut();
                }, 2000);
                return false;
            }
		})

		$(".control-login").click(function(){
		    var phone = $("#phone").val();
            var password = $("#password").val();
           // var password = md5(pas);
            $.ajax({
                url: "user/login?phone="+phone+"&password="+password,
                type: "GET",
                success: function (data) {
                    console.log(data);
                    if(data.obj == "success"){
                        window.location.href = "homePage";
					}else{
                        $(".valid-font").text("手机号或密码错误")
                        $(".dialog").fadeIn();
                        setTimeout(function () {
                            $(".dialog").fadeOut();
                        }, 2000);
					}
                },
                error: function (jqXHR) {
                    console.log("发生错误" + jqXHR.status);
                }
            });

		})

        $("#sinaBtn").click(function () {
            $.ajax({
                url: "login/sina",
                type: "POST",
                dataType: "json",
                success: function (data) {
                    window.location.href = data.oauthUrl;
                },
                error: function (jqXHR) {
                    console.log("发生错误" + jqXHR.status);
                }
            });
        })

        $("#weixinBtn").click(function () {
            $.ajax({
                url: "login/weixin",
                type: "POST",
                dataType: "json",
                success: function (data) {
                    window.location.href = data.oauthUrl;
                },
                error: function (jqXHR) {
                    console.log("发生错误" + jqXHR.status);
                }
            });
        })

        $("#qqBtn").click(function () {
            $.ajax({
                url: "login/qq",
                type: "POST",
                dataType: "json",
                success: function (data) {
                    window.location.href = data.oauthUrl;
                },
                error: function (jqXHR) {
                    console.log("发生错误" + jqXHR.status);
                }
            });
        })
	</script>
</html>
